package com.zlzxm.shoesmarket.view.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zlzxm.shoesmarket.R;

import org.jetbrains.annotations.NotNull;

/**
 * CREATE BY zlzxm ON 4/16/21
 */
public class ADGoodsSizeTag extends BaseQuickAdapter<ADGoodsSizeTag.EntityGoodsSizeTag,
        BaseViewHolder> {
    private int selectPosition = -1;

    public boolean setSelectPosition(int position){

        if(position<0 || position >= getData().size()){

            return false;
        }

        ADGoodsSizeTag.EntityGoodsSizeTag tag =  getData().get(position);

        tag.setSelect(!tag.isSelect);

        notifyDataSetChanged();

        return  tag.isSelect;
    }


    public ADGoodsSizeTag() {
        super(R.layout.item_size_tag);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder,
                           EntityGoodsSizeTag entityGoodsSizeTag) {

        baseViewHolder.itemView.setSelected(entityGoodsSizeTag.isSelect);

        baseViewHolder.setText(R.id.tvSize,entityGoodsSizeTag.getSize());
    }







    public static class EntityGoodsSizeTag {

        private boolean isSelect;

        private String id;

        private String size;

        public EntityGoodsSizeTag( String id, String size) {
            this.id = id;
            this.size = size;
        }

        boolean isSelect() {
            return isSelect;
        }

        void setSelect(boolean select) {
            isSelect = select;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getSize() {
            return size;
        }

        public void setSize(String size) {
            this.size = size;
        }
    }
}
